home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / genlock / ats / ats.c < prev    next >
C/C++ Source or Header  |  1995-02-13  |  5KB  |  198 lines

  1. #define  INTUI_V36_NAMES_ONLY
  2.  
  3. #include "iffp/ilbmapp.h"
  4.  
  5. struct Library *IntuitionBase  = NULL;
  6. struct Library *GfxBase        = NULL;
  7. struct Library *IFFParseBase   = NULL;
  8.  
  9. struct   Screen         *scr = NULL; 
  10. struct   Window         *win = NULL;
  11. struct   IntuiMessage   *msg;
  12. struct   TagItem vc[2];
  13. struct ViewPortExtra *vpe;
  14.  
  15. UWORD pens[] = { ~0 };
  16. struct ILBMInfo  *ilbm = NULL;
  17. LONG my_ifferror = 0L;
  18. int i, limit;
  19.  
  20. LONG    ilbmprops[] = {
  21.                 ID_ILBM, ID_BMHD,
  22.                 ID_ILBM, ID_CMAP,
  23.                 ID_ILBM, ID_CAMG,
  24.                 TAG_DONE
  25.                 };
  26. LONG    ilbmcollects[] = {
  27.                 TAG_DONE
  28.                 };
  29. LONG    ilbmstops[] = {
  30.                 ID_ILBM, ID_BODY,
  31.                 TAG_DONE
  32.                 };
  33.  
  34. UWORD __chip waitPointer[] =
  35. {
  36.     0x0000, 0x0000,     /* reserved, must be NULL */
  37.  
  38.     0x0400, 0x07C0,
  39.     0x0000, 0x07C0,
  40.     0x0100, 0x0380,
  41.     0x0000, 0x07E0,
  42.     0x07C0, 0x1FF8,
  43.     0x1FF0, 0x3FEC,
  44.     0x3FF8, 0x7FDE,
  45.     0x3FF8, 0x7FBE,
  46.     0x7FFC, 0xFF7F,
  47.     0x7EFC, 0xFFFF,
  48.     0x7FFC, 0xFFFF,
  49.     0x3FF8, 0x7FFE,
  50.     0x3FF8, 0x7FFE,
  51.     0x1FF0, 0x3FFC,
  52.     0x07C0, 0x1FF8,
  53.     0x0000, 0x07E0,
  54.  
  55.     0x0000, 0x0000,     /* reserved, must be NULL */
  56. };
  57.  
  58. UWORD __chip transpPointer[] =
  59. {
  60.     0x0000, 0x0000,     /* reserved, must be NULL */
  61.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  62.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  63.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  64.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,    
  65.     0x0000, 0x0000,     /* reserved, must be NULL */
  66. };
  67.  
  68. extern UWORD __chip waitPointer[];
  69. extern UWORD __chip transpPointer[];
  70.  
  71.  
  72. void Give_Up(char *reason)
  73. {
  74.   if(reason) printf("%s.\n",reason);
  75.  
  76.   if(win) CloseWindow(win);
  77.   if(scr) CloseScreen(scr);
  78.   if(ilbm)
  79.   {
  80.     if(ilbm->ParseInfo.iff)     FreeIFF(ilbm->ParseInfo.iff);
  81.     FreeMem(ilbm,sizeof(struct ILBMInfo));
  82.   }
  83.  
  84.   if(IFFParseBase)  CloseLibrary(IFFParseBase);
  85.   if(GfxBase)       CloseLibrary(GfxBase);
  86.   if(IntuitionBase) CloseLibrary(IntuitionBase);
  87.   exit(0);
  88. }
  89.  
  90. void main(int argc, char **argv)
  91. {
  92.   if(argc==0)
  93.   {
  94.     printf("Cannot be run from WB.\n");
  95.     Delay(50);
  96.   }
  97.   if(argc!=2) Give_Up("Usage: prg <iff filename>");
  98.  
  99.   if(!(IntuitionBase=OpenLibrary("intuition.library",0)))
  100.     Give_Up("Can not open Intuition Lib");
  101.   
  102.   if(!(GfxBase=OpenLibrary("graphics.library",0)))
  103.     Give_Up("Can not open Graphics Lib");
  104.  
  105.   if(!(IFFParseBase=OpenLibrary("iffparse.library",0)))
  106.     Give_Up("Can not open Iffparse Lib");
  107.  
  108.   if(!(ilbm = (struct ILBMInfo *)
  109.         AllocMem(sizeof(struct ILBMInfo),MEMF_PUBLIC|MEMF_CLEAR))
  110.     )
  111.     Give_Up("Can not allocate ILBMInfo struct");
  112.  
  113.   ilbm->ParseInfo.propchks    = ilbmprops;
  114.   ilbm->ParseInfo.collectchks = ilbmcollects;
  115.   ilbm->ParseInfo.stopchks    = ilbmstops;
  116.  
  117.   if(!(ilbm->ParseInfo.iff = AllocIFF()  ))
  118.     Give_Up("Can not allocate IFF handle");
  119.  
  120.   if(my_ifferror=queryilbm(ilbm, argv[1]))
  121.     Give_Up(IFFerr(my_ifferror));
  122.   
  123.   /* Skaf noget at vise billedet på. */
  124.  
  125.   if(!(scr=OpenScreenTags
  126.   (
  127.    NULL,
  128.    SA_Pens, (ULONG)pens,
  129.    SA_Depth, MIN(ilbm->Bmhd.nPlanes, MAXAMDEPTH),
  130.    SA_Width, MAX(ilbm->Bmhd.pageWidth, ilbm->Bmhd.w),
  131.    SA_Height, MAX(ilbm->Bmhd.pageHeight,ilbm->Bmhd.h),
  132.    SA_DisplayID, HIRESLACE_KEY,
  133.    SA_Title, "Mon dette er en lang nok streng?",
  134.    SA_Type, CUSTOMSCREEN,
  135.    SA_Overscan, OSCAN_MAX,
  136.    TAG_DONE
  137.   )   ))
  138.     Give_Up("Can not open screen");
  139.   
  140.   if(!(win=OpenWindowTags
  141.       (NULL,    
  142.        WA_CustomScreen, scr,
  143.        WA_Borderless, TRUE,
  144.        WA_Activate, TRUE,
  145.        WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_MOUSEBUTTONS,
  146.        TAG_DONE
  147.       )
  148.     ))
  149.       Give_Up("Can not open window");
  150.  
  151.   ilbm->scr=scr;
  152.   ilbm->win=win;
  153.   ilbm->wrp=win->RPort;
  154.   ilbm->srp=&scr->RastPort;
  155.   ilbm->vp=&scr->ViewPort;
  156.  
  157.   SetPointer(win, waitPointer, 16, 16, -6, 0);                 
  158.   if((my_ifferror = loadilbm(ilbm, argv[1])  ))
  159.     Give_Up(IFFerr(my_ifferror));
  160.  
  161.   closeifile(&ilbm->ParseInfo);
  162.  
  163.   /* På dette tidspunkt mener jeg, jeg har gjort alt
  164.      relevant fra ILBMLoad.c eksemplet; dette er hvor
  165.      de venter på input. Så her kan jeg lave, hvad 
  166.      jeg nu har lyst til efter at billedet ER kommet ind.
  167.   */
  168.  
  169.   vc[0].ti_Tag=VTAG_VIEWPORTEXTRA_GET;
  170.   vc[0].ti_Data=NULL;
  171.   vc[1].ti_Tag=TAG_END;
  172.   vc[1].ti_Data=NULL;
  173.  
  174.   VideoControl(scr->ViewPort.ColorMap,vc);
  175.   vpe=(struct ViewPortExtra *) vc[0].ti_Data;
  176.   limit = scr->Height-
  177.      (vpe->DisplayClip.MaxY - vpe->DisplayClip.MinY);
  178.  
  179.   SetPointer(win, transpPointer, 16, 16, -6, 0);
  180.  
  181.   Wait(1<<win->UserPort->mp_SigBit);
  182.   ReplyMsg(GetMsg(win->UserPort));
  183.  
  184.   for(i=0; i<limit; i+=2)
  185.   {
  186.     scr->ViewPort.RasInfo->RyOffset=i;
  187.     WaitTOF();
  188.     ScrollVPort(&scr->ViewPort);
  189.   }
  190.   Wait(1<<win->UserPort->mp_SigBit);
  191.   ReplyMsg(GetMsg(win->UserPort));
  192.  
  193.   unloadilbm(ilbm);
  194.  
  195.   Give_Up("");
  196. }
  197.  
  198.